package com.jackstraw.jack_base.rules.service.impl;

import com.jackstraw.jack_base.datasource.common.aspect.annotation.DataSourceNameCut;
import com.jackstraw.jack_base.datasource.common.entity.enums.DataSourceTypeEnum;
import com.jackstraw.jack_base.datasource.mybatis.base.service.impl.MyBatisServiceImpl;
import com.jackstraw.jack_base.rules.dao.database.RelationRipDao;
import com.jackstraw.jack_base.rules.entity.bo.RelationRipBo;
import com.jackstraw.jack_base.rules.entity.mapstruct.RelationRipMapstruct;
import com.jackstraw.jack_base.rules.entity.po.RelationIpKeyPo;
import com.jackstraw.jack_base.rules.entity.po.RelationRipPo;
import com.jackstraw.jack_base.rules.entity.po.RelationRipPoExample;
import com.jackstraw.jack_base.rules.service.RelationRipService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

/**
 * 场景规则组关系表  service实现类
 *
 * @author zhaozhao 945514650@qq.com
 * @since version:1.0 generatorDate:2022-12-04 14:28:28
 */
@Slf4j
@DataSourceNameCut(dataSourceName = "dataBaseName1", dataSourceTypeEnum = DataSourceTypeEnum.database)
public class RelationRipServiceImpl
        extends MyBatisServiceImpl<RelationRipDao, RelationRipPo, RelationRipBo, RelationIpKeyPo<RelationRipPo>, RelationRipPoExample>
        implements RelationRipService {

    @Autowired
    private RelationRipMapstruct relationRipMapstruct;

    @Override
    protected RelationRipPoExample pe(Map<String, Object> params) {
        RelationRipPoExample pe = super.pe(params);
        //默认查询主键
        pe.addKey(params);
        return pe;
    }

    @Override
    public List<RelationRipBo> queryAllByRuleGroupId(Long ruleGroupId) {
        List<RelationRipPo> relationRipPos = this.getDao().selectByRuleGroupId(ruleGroupId);
        return relationRipMapstruct.boToS(relationRipPos);
    }
}
